<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<c:forEach items="${orders}" var="order">
	<div id="o${order.id}">
		<div class="wsmj1">
			<p>
				<fmt:formatDate value="${ order.createdAt }" pattern="yyyy-MM-dd HH:mm:ss" />
			</p>
			<span>状态:${order.state>=30?'已支付':orderState[order.state]}</span>

			<c:if test="${(state==0 || state==10)&&(order.state==10||order.state==20)}">
				<input type="button" value="取消订单" onclick="cancelOrder('${order.id}');" />
				<input type="button" value="去支付" onclick="payOrder('${order.code}');" />
			</c:if>
			<c:if test="${(state==0 || state==21)&&order.state==21}">
				<input type="button" value="取消订单" onclick="cancelPayOrder('${order.id}');" class="cancel" />
			</c:if>
		</div>
		<c:set var="sum" value="0"></c:set>
		<c:set var="canCancel" value="0"></c:set>
		<c:forEach items="${order.storageOrder}" var="storageOrder">
			<div id="s${storageOrder.id}">
				<div class="wsmj2">
					<span>${storageOrder.storage.name}</span>
					<span>状态:${orderState[storageOrder.state]}</span>
					<a href="javascript:gotoHtml('/order/detail.htm?storageOrderId=${storageOrder.id}');" style="color: #4672d5; margin-left: 10px;">订单详情</a>
					<c:if test="${(state==0 || state==31)&&storageOrder.state==31}">
						<a href="javascript:beforeReceipt('${storageOrder.id}');" style="color: #4672d5; float: right; margin-right: 25px;">确认收货</a>
					</c:if>
				</div>
				<c:forEach items="${storageOrder.goodsOrder}" var="goodsOrder">
					<c:set var="sum" value="${sum+goodsOrder.num}"></c:set>
					<c:set var="canCancel" value="${canCancel+(goodsOrder.state!=21?1:0)}"></c:set>
					<div id="g${goodsOrder.id}">
						<div class="wsmj3">
							<table width="946" border="0" class="table2">
								<tr>
									<td style="width: 100px;" class="td2">
										<table>
											<tr>
												<td><img src="${goodsOrder.image }" /></td>
											</tr>
										</table>
									</td>
									<td style="width: 326px; text-align: left; padding-left: 10px; padding-right: 10px; text-align: left;" class="td2">
										<table>
											<tr style="height: 100px;">
												<td><a>${goodsOrder.name}</a>
													<p>${goodsOrder.goodsSku.specName}</p></td>
											</tr>
										</table>
									</td>
									<td style="width: 100px; text-align: center;" class="td2">
										<table style="width: 100%;">
											<tr style="height: 100px;">
												<td><c:if test="${goodsOrder.points>=0}">
										￥
										<fmt:formatNumber value="${goodsOrder.price/100}" pattern="#,###.##" />
													</c:if> <c:if test="${goodsOrder.points<0}">
										积分${-goodsOrder.points}
										</c:if></td>
											</tr>
										</table>
									</td>
									<td style="width: 100px; text-align: center;" class="td2">
										<table style="width: 100%;">
											<tr style="height: 100px;">
												<td>${goodsOrder.num}</td>
											</tr>
										</table>
									</td>
									<td style="width: 100px; text-align: center;" class="td2">
										<table style="width: 100%;">
											<tr style="height: 100px;">
												<td>￥ <fmt:formatNumber value="${goodsOrder.totals/100}" pattern="#,###.##" />
												</td>
											</tr>
										</table>
									</td>
									<td style="width: 100px;" class="td2">
										<p>状态:${orderState[goodsOrder.state]}</p>
									</td>
									<td style="width: 100px; border: none;" class="td2"><c:if
											test="${(state==0 || state==40)&&goodsOrder.commentState!=80&&(goodsOrder.state==40||goodsOrder.state==41||goodsOrder.state==60||goodsOrder.state==70)}">
											<a href="javascript:doComment('${goodsOrder.id}');" style="color: #4672d5">去评价</a>
											<br />
										</c:if> <c:if test="${goodsOrder.state==31}">
											<a href="javascript:gotoHtml('/order/detail.htm?storageOrderId=${storageOrder.id}');" style="color: #4672d5">查看物流</a>
											<br />
										</c:if> <c:if test="${goodsOrder.state==30||goodsOrder.state==31||goodsOrder.state==32||goodsOrder.state==40||goodsOrder.state==41}">
											<a href="javascript:gotoHtml('/buyer/salesreturn.htm?goodsOrderIds=${goodsOrder.id}');" style="color: #4672d5">申请售后</a>
										</c:if></td>
								</tr>
							</table>
						</div>
					</div>
				</c:forEach>
			</div>
		</c:forEach>
		<c:if test="${canCancel!=0}">
			<div class="noCancel" style="display: none"></div>
		</c:if>
		<div class="wsmj4">
			<h2>
				商品金额：￥
				<fmt:formatNumber value="${order.goodsAmount/100}" pattern="#,###.##" />
				&nbsp;&nbsp;&nbsp;优惠金额：-￥
				<fmt:formatNumber value="${order.discountAmount/100}" pattern="#,###.##" />
				&nbsp;&nbsp;&nbsp;运费：￥
				<fmt:formatNumber value="${order.freightAmount/100}" pattern="#,###.##" />
				&nbsp;&nbsp;&nbsp;总金额：￥
				<fmt:formatNumber value="${order.resultAmount/100}" pattern="#,###.##" />
			</h2>
		</div>
	</div>

</c:forEach>
<input type="hidden" id="pageCount" value="${count}" />
